package com.cskaoyan.mall.product.service.impl;

import com.cskaoyan.mall.product.converter.dto.SaleAttributeInfoConverter;
import com.cskaoyan.mall.product.dto.SaleAttributeInfoDTO;
import com.cskaoyan.mall.product.mapper.SaleAttrInfoMapper;
import com.cskaoyan.mall.product.model.SaleAttributeInfo;
import com.cskaoyan.mall.product.service.SalesAttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Pudding
 * @Date 2024/7/1 17:39
 */
@Service
public class SalesAttributeServiceImpl implements SalesAttributeService {

    @Autowired
    SaleAttrInfoMapper saleAttrInfoMapper;
    @Autowired
    SaleAttributeInfoConverter saleAttributeInfoConverter;

    //1. 查询所有的销售属性
    @Override
    public List<SaleAttributeInfoDTO> getSaleAttrInfoList() {

        //1.1 查询所有的销售属性
        List<SaleAttributeInfo> saleAttributeInfos = saleAttrInfoMapper.selectList(null);
        //1.2 将PO对象转换为DTO对象
        List<SaleAttributeInfoDTO> saleAttributeInfoDTOS = saleAttributeInfoConverter.saleAttributeInfoPOs2DTOs(saleAttributeInfos);

        return saleAttributeInfoDTOS;
    }
}
